function submit() {
  //创建元素
  var f = document.createElement("div"),
    a = document.createElement("div"),
    p = document.createElement("p"),
    btn3 = document.createElement("div"),
    link1 = document.createElement("a"),
    p2 = document.createElement("p"),
    pText = document.createTextNode("提示"),
    pText2 = document.createTextNode("是否发布问卷？"),
    p3 = document.createElement("p"),
    pText3 = document.createTextNode(
      "(此问卷截止日期为" + localStorage.getItem("date") + ")"
    ),
    btnText3 = document.createTextNode("x"),
    btn1 = document.createElement("div"),
    btn2 = document.createElement("div"),
    btnText1 = document.createTextNode("确定"),
    btnText2 = document.createTextNode("取消");
  a.className = "submit";
  //判断是否填写时间
  if (localStorage.getItem("date") == " ：请先选截止时间") {
    alert("请先填写截止时间！");
    return;
  }

  //localStorage.setItem("date", " ：请先选截止时间");

  // 控制样式
  css(f, {
    width: "100%",
    height: "777px",
    position: "fixed",
    top: "0px",
    "background-image": "url(../img/Background1.png)",
    "z-index": "1",
  });
  css(a, {
    position: "fixed",
    left: "0",
    right: "0",
    top: "20%",
    width: "350px",
    height: "180px",
    margin: "0 auto",
    "background-color": "white",
    "font-size": "15px",
    "border-radius": "4px",
    "box-shadow": "rgb(177, 177, 177) 0px 2px 5px",
    "z-index": "10",
  });
  css(p, {
    height: "35px",
    margin: "0",
    background: "rgb(211, 208, 208)",
    "font-weight": "600",
    "line-height": "35px",
    "border-radius": "4px",
    "padding-left": "20px",
  });
  css(p2, {
    height: "35px",
    "line-height": "35px",
    "padding-left": "20px",
  });
  css(p3, {
    height: "35px",
    "line-height": "35px",
    "padding-left": "20px",
  });
  css(btn1, {
    position: "relative",
    left: "110px",
    right: "0",
    top: "23%",
    width: "50px",
    height: "23px",
    color: "black",
    "border-radius": "2px",
    border: "solid gray 1px",
    // "background": "rgb(241, 112, 53)",
    "text-align": "center",
    display: "inline-block",
  });
  css(btn2, {
    position: "relative",
    left: "140px",
    right: "0",
    top: "23%",
    width: "50px",
    height: "23px",
    border: "solid gray 1px",
    "text-align": "center",
    display: "inline-block",
    "border-radius": "2px",
  });
  css(btn3, {
    width: "30px",
    display: "inline-block",
    "margin-left": "270px",
    "text-align": "center",
  });
  // 内部结构套入
  link1.appendChild(btnText1);
  btn2.appendChild(btnText2);
  btn3.appendChild(btnText3);
  link1.setAttribute("href", "./list.html");
  btn1.appendChild(link1);
  p.appendChild(pText);
  p.appendChild(btn3);
  p2.appendChild(pText2);
  p3.appendChild(pText3);
  f.appendChild(a);
  a.appendChild(p);
  a.appendChild(p2);
  a.appendChild(p3);
  a.appendChild(btn1);
  a.appendChild(btn2);

  // 整体显示到页面内
  document.getElementsByTagName("body")[0].appendChild(f);

  // 确定绑定点击事件删除标签
  btn1.onclick = function () {
    a.parentNode.removeChild(a);
    f.parentNode.removeChild(f);

    let today = new Date();
    let stringToday = today.toLocaleDateString();
    let temp = stringToday.split("/");
    let currentDate = "";
    for (let i = 0; i < temp.length; i++) {
      if (i != temp.length - 1) {
        if (temp[i].length == 1) {
          temp[i] = 0 + temp[i];
        }
        currentDate = currentDate + temp[i] + "-";
      } else {
        if (temp[i].length == 1) {
          temp[i] = 0 + temp[i];
        }
        currentDate = currentDate + temp[i];
      }
    }

    let selectedDate = localStorage.getItem("date");

    // console.log(
    //   "------- submit.js 行 141 currentDate = " +
    //     currentDate +
    //     " selectedDate = " +
    //     selectedDate
    // );
    localStorage.setItem("currentDate", currentDate);

    let currentOperatedQuestionnaire = JSON.parse(
      localStorage.getItem("currentOperatedQuestionnaire")
    );

    if (selectedDate >= currentDate) {
      currentOperatedQuestionnaire.state = 1;
    } else {
      currentOperatedQuestionnaire.state = 2;
    }

    localStorage.setItem(
      "currentOperatedQuestionnaire",
      JSON.stringify(currentOperatedQuestionnaire)
    );

    let indexOfCurrentOperatedQuestionnaire = JSON.parse(
      localStorage.getItem("indexOfcurrentOperatedQuestionnaire")
    );
    let questionnaires = JSON.parse(localStorage.getItem("Questionnaires"));
    questionnaires[indexOfCurrentOperatedQuestionnaire] =
      currentOperatedQuestionnaire;
    localStorage.setItem("Questionnaires", JSON.stringify(questionnaires));
  };
  btn2.onclick = function () {
    a.parentNode.removeChild(a);
    f.parentNode.removeChild(f);
  };
  btn3.onclick = function () {
    a.parentNode.removeChild(a);
    f.parentNode.removeChild(f);
  };
}

function css(targetObj, cssObj) {
  var str = targetObj.getAttribute("style")
    ? targetObj.getAttribute("style")
    : "";
  for (var i in cssObj) {
    str += i + ":" + cssObj[i] + ";";
  }
  targetObj.style.cssText = str;
}
